//
//  ViewController.swift
//  61.新工程表情键盘
//
//  Created by apple on 16/3/7.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

// 键盘的高度216
class ViewController: UIViewController {

    @IBOutlet weak var textView: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()
        
//        let vc = TestViewController()
//        addChildViewController(vc)

        // 设置inputView后再弹出的键盘就是这个inputView
        textView.inputView = emoticonKeyboard
        
        textView.becomeFirstResponder()
        
        let packages = CZEmoticonManager.sharedManager.emoticonPackages
        print("packages: \(packages)")
//        testEmoji()
    }
    
    private func testEmoji() {
        let code = "0x1f603"
        
        // 扫描对象
        let scanner = NSScanner(string: code)
        
        // result: UnsafeMutablePointer<UInt32>
        var result: UInt32 = 0
        
        scanner.scanHexInt(&result)
        
        print("result: \(result)")
        
        let scalar = UnicodeScalar(result)
        
        textView.text = String(Character(scalar))
    }

    @IBAction func buttonClick(sender: AnyObject) {
        print(NSHomeDirectory())
    }
    
    
    // MARK: - 懒加载
    /// 表情键盘的view
    private lazy var emoticonKeyboard: CZEmoticonKeyboard = {
        let view = CZEmoticonKeyboard(frame: CGRect(origin: CGPointZero, size: CGSize(width: UIScreen.mainScreen().bounds.width, height: 216)))
        
        return view
    }()
}

